FLUSH_BUFFER: PUSH AX ;Save the current character.
MOV SI,OFFSET ESC_BUFFER ;Point to the sequence buffer.
MOV CX,ESC_COUNT ;Count of buffered characters.
NEXT_FLUSH: LODSB ;Retrieve one.
PUSH CX ;Save counter and pointer.
PUSH SI
CALL WRITE_CHAR ;Write character to screen.
POP SI ;Restore counter and pointer.
POP CX
LOOP NEXT_FLUSH ;Flush entire buffer.
POP AX ;Retrieve last character.
CALL WRITE_CHAR ;Write it also.
FLUSH_END: MOV ESC_COUNT,0 ;Reset counter.
MOV ANSI_STATE,OFFSET ESC_STATE ;Back to Esc state.
MOV NUMBER_COUNT,0 ;Reset parameter counter.
PUSH CS ;Pointá b b b b b b ■ b b b b b b b ■ b b b b á b b b b b b b b b b b b b b b b á b b b b b b b b b b b á b b b b á b b b b b b b á b b b b b OV CX,FORMAT_LENGTH ; return, linefeed, backspace
REPNZ SCASB ; and bell via
JZ WRITE_TTY ; TTY.
CALL GET_BIOS_DATA ;Get BIOS video data.
CMP AL,9 ;Is character a TAB?
JNZ CK_ACTIVE ;If no, process normally.
MOV CX,CURSOR_POSN ;Else, expand TAB to
AND CX,7 ; appropriate space characters.
NEG CX
ADD CX,8
NEXT_TAB: PUSH CX
MOV AL,SPACE
CALL CK_ACTIVE
POP CX
LOOP NEXT_TAB
RET
CK_ACTIVE: TEST STATUS,OFF ;Is ANSI OFF?
JNZ WRITE_TTY ;If yes, write via BIOS TTY.
CK_FAST: CALL CK_SLOW_TEXT ;Is ANSI SLOW or in graphics